package com.ruoyi.business.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.business.domain.FreightPaymentVoucher;
import com.ruoyi.business.domain.vo.FreightPaymentVoucherVo;
import com.ruoyi.common.core.mapper.BaseMapperPlus;

/**
 * 运单打款凭证Mapper接口
 *
 * @author ruoyi
 * @date 2024-04-20
 */
public interface FreightPaymentVoucherMapper extends BaseMapperPlus<FreightPaymentVoucherMapper, FreightPaymentVoucher, FreightPaymentVoucherVo> {

    /**
     * 根据运单id删除打款凭证
     *
     * @param freightId
     * @return
     */
    default boolean deleteByFreightId(Long freightId) {
        return delete(new LambdaQueryWrapper<FreightPaymentVoucher>()
            .eq(FreightPaymentVoucher::getFreightId, freightId)
        ) > 0;
    }

    /**
     * 根据运单id查询打款凭证
     *
     * @param freightId
     */
    default FreightPaymentVoucherVo selectVoByFreightId(Long freightId) {
        return selectVoOne(new LambdaQueryWrapper<FreightPaymentVoucher>()
            .eq(FreightPaymentVoucher::getFreightId, freightId)
            .last("limit 1")
        );
    }
}
